<template>
    <div>
        <h3 style="padding-left: 30px;padding-top: 30px;">启动页</h3>
        <div class="animate__animated animate__fadeIn">
            <img src="../../utils/启动.png" style="width: 90%;height: 400px;margin-left:5%;" />
        </div>
        <h1 style="text-align:center;padding-top: 30px;" class="animate__animated animate__fadeIn">智慧云医疗</h1>
    </div>
</template>

<script>
import { ref, onMounted, onUnmounted } from 'vue';
import { useRouter } from 'vue-router';
import 'animate.css';
export default {
    setup() {
        const count = ref(3); // 设置初始计数为3
        const router = useRouter();
        let timer = null;
        // 定时器逻辑
        const startTimer = () => {
            timer = setInterval(() => {
                if (count.value > 0) {
                    count.value--; // 减少计数器
                } else {
                    clearInterval(timer);
                    router.push('/login'); // 跳转到'/login'页面
                }
            }, 1000);
        };
        const login = () => {
            clearInterval(timer); // 清除定时器
            router.push('/login'); // 跳转到'/login'页面
        };
        onMounted(() => {
            startTimer();
        });
        onUnmounted(() => {
            clearInterval(timer); // 确保组件卸载时清除定时器
        });
        return {
            count,
            login,
        };
    },
};
</script>

<style scoped></style>